$(function () {
    $('ul.sidebar-menu li').click(function () {
        var li = $('ul.sidebar-menu li.active');
        li.removeClass('active');
        $(this).addClass('active');
    });


    $('.myLeftMenu').click(function (e) {
        $('.activeLine').each(function (){
            $(this).removeClass('activeLine')
        });
        var url = $(this).attr('data');
        //  console.log(url);
        var token=localStorage.getItem("token");
        $('#container').load(url+"?token="+token);
        $(this).addClass('activeLine');
        $("#mainshow").html('');
        $("#mainshow").append('<li ><a class="" href="javascript:void(0)"><i class="fa fa-dashboard"></i>当前位置</a></li>');
        var dom=$(this).parent().parent().parent().find(".menu");
        var text=dom.text();
        $("#mainshow").append('<li><a class="" href="javascript:void(0)"><i class="fa"></i>'+text+'</a></li>');
        var thText=$(this).text();
        $("#mainshow").append('<li><a  id="threeMenu" data="'+url+'" href="javascript:void(0)"><i class="fa"></i>'+thText+'</a></li>');

    });

    $("#threeMenu").click(function (e) {
        var token=localStorage.getItem("token");
        var url = $(this).attr('data');
        $('#container').load(url+"?token="+token);
    });
    var time = new Date();
    var content =time.toLocaleString();
    $("#time").text(content);
})

//发送POST请求跳转到指定页面
function httpPost(URL, PARAMS) {
    var temp = document.createElement("form");
    temp.action = URL;
    temp.method = "post";
    temp.style.display = "none";

    for (var x in PARAMS) {
        var opt = document.createElement("textarea");
        opt.name = x;
        opt.value = PARAMS[x];
        temp.appendChild(opt);
    }

    document.body.appendChild(temp);
    temp.submit();

    return temp;
}